package net.ocps.tchs.GovSim;


import aurelienribon.tweenengine.Tween;
import aurelienribon.tweenengine.TweenManager;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;

public class SplashScreen implements Screen{

	private Tween tween;
	private TweenManager tweenmanage;           
	private SpriteBatch batch;
	private Texture texture;
	private Sprite sprite;
	private OrthographicCamera camera;
	screenSwitcher game;
	
	
	
	
	
	public SplashScreen(screenSwitcher game) {
		float w = Gdx.graphics.getWidth();
		float h = Gdx.graphics.getHeight();
		this.game = game;
		camera = new OrthographicCamera(1, h/w);
		batch = new SpriteBatch();
		texture = new Texture(Gdx.files.internal("data/libgdx.png"));
		texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
		
		TextureRegion region = new TextureRegion(texture, 0, 0, 512, 275);
		
		sprite = new Sprite(region);
		sprite.setSize(0.9f, 0.9f * sprite.getHeight() / sprite.getWidth());
		sprite.setOrigin(sprite.getWidth()/2, sprite.getHeight()/2);
		sprite.setPosition(-sprite.getWidth()/2, -sprite.getHeight()/2);
	}



	@Override
	public void render(float delta) {
		batch.begin();
		sprite.draw(batch);
		batch.end();
	}

	@Override
	public void resize(int width, int height) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void show() {
		tweenmanage = new TweenManager();
		texture = new Texture(Gdx.files.internal("ui/TitleScreen.png"));
		TextureRegion region = new TextureRegion(texture, 0, 0, 512, 512);
		sprite = new Sprite(region);

		Tween.registerAccessor(Sprite.class, new SpriteAccessor());
		Tween.set(sprite, SpriteAccessor.Alpha).start(tweenmanage);
		Tween.to(sprite, SpriteAccessor.Alpha, 2).target(1).start(tweenmanage);
		Tween.to(sprite, SpriteAccessor.Alpha, 2).target(0).delay(2).start(tweenmanage);
		
		
		
	}

	@Override
	public void hide() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub
		
	}

}
